package com.frontier.sentinelservice8005.controller;

import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeSlot;
import com.alibaba.nacos.client.config.impl.ClientWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * 测试网关控制层
 *
 * @author YLS-XuXu
 * @time 2022/2/24
 */
@RestController
public class TestSentinelController {


    /**
     * 网关负载均衡测试接口
     *
     * @return 测试结果
     */
    @GetMapping("/testSentinel")
    public String testSentinel() {
//        int xx=1/0;
        return "cloud-alibaba-sentinel-provider8005";
    }


    /**
     * 测试平均响应时长熔断策略。
     * 配置平均相应时常为1s，当平均相应时常>1s时， 在接下来时间窗口内，所有的请求都被熔断并且平均相应时间>1s
     *
     * @return java.lang.String
     */
    @GetMapping("/testDegradeGradeRt")
    public String testDegradeGradeRt() throws InterruptedException {
        Thread.sleep(3000);
        return "cloud-alibaba-sentinel-provider8005";
    }
}
